package iscript.gameFramework.GameLite.graphics.bitmaps 
{
	import flash.display.Bitmap;
	import flash.display.BitmapData; 
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.utils.ByteArray;
	/**
	 * ...
	 * @author raymond
	 */
	public class BitmapDataTool  
	{
		
		static  public function  MovieClipToBitmapData(bitmapDataDraw:BitmapDataDraw):Vector.<BitmapData> {
			  var data:Vector.<BitmapData> = new Vector.<BitmapData>();
			  var target:MovieClip = MovieClip(bitmapDataDraw.target)
			  for (var i:int = 1; i <=target.totalFrames; i++) 
			  {
				  target.gotoAndStop(i);
				  data.push(bitmapDataDraw.renderTarget(target));
			  }
			  return data;
			}
	    	
		 
		/**
		 * 鼠标点击位图的坐标点是否透明
		 * @param	bm
		 * @return
		 */
		static	public function IsTransparentByMousePoint(bm:Bitmap):Boolean {
			if (bm.stage == null) return true;
			var bd:BitmapData = bm.bitmapData;
			var displayPoint:Point = toStagePoint(bm);
			return (bd.getPixel32(bm.stage.mouseX-displayPoint.x,bm.stage.mouseY-displayPoint.y)>>24& 0xFF)!=0	
		}
			
		static private function toStagePoint(target:DisplayObject):Point {
		   var result:Point = new Point(); 
		   while ( target != null) {
					result.x += target.x;
					result.y += target.y;
					target = target.parent;
				 }
			 return  result;
		}	
	}
}